/***********************************************************************************************************************************
 * Name:	JobSchedules_Staging.sql
 * Author:	Frank Figearo (frank.figearo@us.bbaaviation.com|frank@sqlnerd.me)
 * Summary:	
 */
USE msdb;
GO

DECLARE @schedule_name NVARCHAR(128);
SET @schedule_name= N'• Database Backup & Maintenance';
BEGIN TRY;
  EXECUTE msdb.dbo.sp_delete_schedule @schedule_name= @schedule_name, @force_delete= 1;
END TRY BEGIN CATCH END CATCH;
EXECUTE msdb.dbo.sp_add_schedule 
	@schedule_name			= @schedule_name, 
	@enabled				= 1,
	@freq_type				= 4,
	@freq_interval			= 1,
	@freq_subday_type		= 1,
	@freq_subday_interval	= 0,
	@freq_relative_interval	= 0,
	@freq_recurrence_factor	= 0,
	@active_start_date		= 20120920,
	@active_end_date		= 99991231,
	@active_start_time		= 221112, 
	@active_end_time		= 235959;
BEGIN TRY;
  EXECUTE msdb.dbo.sp_attach_schedule @job_name= @schedule_name, @schedule_name= @schedule_name;
END TRY BEGIN CATCH END CATCH;
GO

DECLARE @schedule_name NVARCHAR(128);
SET @schedule_name= N'• Database TLog Backup';
BEGIN TRY;
  EXECUTE msdb.dbo.sp_delete_schedule @schedule_name= @schedule_name, @force_delete= 1;
END TRY BEGIN CATCH END CATCH;
EXECUTE msdb.dbo.sp_add_schedule
	@schedule_name			= @schedule_name,
	@enabled				= 1,
	@freq_type				= 4,
	@freq_interval			= 1,
	@freq_subday_type		= 8,
	@freq_subday_interval	= 1,
	@freq_relative_interval	= 0,
	@freq_recurrence_factor	= 0,
	@active_start_date		= 20120920,
	@active_end_date		= 99991231,
	@active_start_time		= 3456,
	@active_end_time		= 235959;
BEGIN TRY;
  EXECUTE msdb.dbo.sp_attach_schedule @job_name= @schedule_name, @schedule_name= @schedule_name;
END TRY BEGIN CATCH END CATCH;
GO

DECLARE @schedule_name NVARCHAR(128);
SET @schedule_name= N'• Purge History';
BEGIN TRY;
  EXECUTE msdb.dbo.sp_delete_schedule @schedule_name= @schedule_name, @force_delete= 1;
END TRY BEGIN CATCH END CATCH;
EXECUTE msdb.dbo.sp_add_schedule
	@schedule_name			= @schedule_name,
	@enabled				= 1,
	@freq_type				= 8,
	@freq_interval			= 1,
	@freq_subday_type		= 1,
	@freq_subday_interval	= 0,
	@freq_relative_interval	= 0,
	@freq_recurrence_factor	= 1,
	@active_start_date		= 20120920,
	@active_end_date		= 99991231,
	@active_start_time		= 231213,
	@active_end_time		= 235959
BEGIN TRY;
  EXECUTE msdb.dbo.sp_attach_schedule @job_name= @schedule_name, @schedule_name= @schedule_name;
END TRY BEGIN CATCH END CATCH;
GO